import React,{Suspense} from 'react'
import {BrowserRouter,Navigate,Route,Routes} from 'react-router-dom'
import config from './config'

interface Ly{
  path:string,
  to?:string,
  component?:any,
  children?:Ly[],
}
export default function vie() {
  const btn=(arr:Ly[])=>{
return arr.map((a,b)=>{
  return <Route key={b} path={a.path}
   element={a.to?<Navigate to={a.to}></Navigate>:<a.component></a.component>}>
    {a.children&&btn(a.children)}
   </Route>
})
  }
  return (
    <BrowserRouter>vie
    <Suspense fallback='加载'>
    <Routes>
{btn(config)}
    </Routes>
    </Suspense>
    </BrowserRouter>
  )
}
